import React, { lazy } from "react";

// 懒加载页面组件
const Home = lazy(() => import("../pages/Home"));
const StockRecords = lazy(() => import("../pages/StockRecords"));
const Messages = lazy(() => import("../pages/Messages"));
const Calendar = lazy(() => import("../pages/Calendar"));
const Profile = lazy(() => import("../pages/Profile"));
const Settings = lazy(() => import("../pages/Settings"));

const Login = lazy(() => import("../pages/Auth"));
const NotFound = lazy(() => import("../pages/NotFound.tsx"));
const Forbidden = lazy(() => import("../pages/Forbidden.tsx"));

// 路由元信息类型
export interface RouteMeta {
  title: string;
  requiresAuth: boolean;
  roles?: string[];
  permissions?: string[];
}

// 自定义路由对象类型
export interface CustomRoute {
  path: string;
  element: React.ReactElement;
  meta?: RouteMeta;
}

// 路由配置
export const routes: CustomRoute[] = [
  {
    path: "/",
    element: <Home />,
    meta: {
      title: "工作台",
      requiresAuth: true,
    },
  },
  {
    path: "/stocks",
    element: <StockRecords />,
    meta: {
      title: "数据管理",
      requiresAuth: true,
    },
  },
  {
    path: "/messages",
    element: <Messages />,
    meta: {
      title: "消息中心",
      requiresAuth: true,
    },
  },
  {
    path: "/calendar",
    element: <Calendar />,
    meta: {
      title: "日程管理",
      requiresAuth: true,
    },
  },
  {
    path: "/profile",
    element: <Profile />,
    meta: {
      title: "个人资料",
      requiresAuth: true,
    },
  },
  {
    path: "/settings",
    element: <Settings />,
    meta: {
      title: "系统设置",
      requiresAuth: true,
    },
  },

  {
    path: "/login",
    element: <Login />,
    meta: {
      title: "登录",
      requiresAuth: false,
    },
  },
  {
    path: "/403",
    element: <Forbidden />,
    meta: {
      title: "访问被拒绝",
      requiresAuth: false,
    },
  },
  {
    path: "/404",
    element: <NotFound />,
    meta: {
      title: "页面未找到",
      requiresAuth: false,
    },
  },
  {
    path: "*",
    element: <NotFound />,
    meta: {
      title: "页面未找到",
      requiresAuth: false,
    },
  },
];
